#include "videoprocessor.h"

VideoProcessor::VideoProcessor(QObject *parent) : QObject(parent)
{

}

void VideoProcessor::startVideo()
{
    using namespace cv;
    VideoCapture camera(0);
    Mat inFrame, outFrame;
    stopped = false;
    while(camera.isOpened() && !stopped)
    {
        camera >> inFrame;
        if(inFrame.empty())  continue;

        bitwise_not(inFrame, outFrame); //按位取反
        //发送显示图像的信号（信号含参）
        emit inDisplay( QPixmap::fromImage( QImage(inFrame.data,inFrame.cols,inFrame.rows,inFrame.step,QImage::Format_RGB888).rgbSwapped()));
        emit outDisplay( QPixmap::fromImage( QImage(outFrame.data,outFrame.cols,outFrame.rows,outFrame.step,QImage::Format_RGB888).rgbSwapped()));
    }
}

void VideoProcessor::stopVideo()
{
    stopped = true;
}
